package com.atguigu.system.service;

import com.atguigu.common.utils.BeanUtils;
import com.atguigu.model.system.SysOperLog;
import com.atguigu.model.vo.operlog.SysOperLogQueryReqVo;
import com.atguigu.model.vo.operlog.SysOperLogQueryRespVo;
import com.atguigu.system.manager.SysOperLogManager;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * OperLogServiceImpl
 * </p>
 *
 * @author flyduck
 * @since 2023/10/26
 */
@Service
public class SysOperLogServiceImpl implements SysOperLogService {

    @Autowired
    private SysOperLogManager sysOperLogManager;

    @Override
    public void saveSysLog(SysOperLog sysOperLog) {
        sysOperLogManager.save(sysOperLog);
    }

    /**
     * 获取分页列表
     * @param pageParam
     * @param sysOperLogQueryVo
     * @return
     */
    public IPage<SysOperLogQueryRespVo> getPageList(Page<SysOperLog> pageParam, SysOperLogQueryReqVo sysOperLogQueryVo) {
        return sysOperLogManager.getPageList(pageParam,sysOperLogQueryVo);
    }

    /**
     * 根据id查询
     * @param id
     * @return
     */
    public SysOperLogQueryRespVo getById(Long id) {
        SysOperLog sysOperLog = sysOperLogManager.getById(id);
        return BeanUtils.toBean(sysOperLog, SysOperLogQueryRespVo.class);
    }
}
